package cn.kgc.shiro;

import cn.kgc.shiro.config.CustomerRealm;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.subject.Subject;

/**
 * @author 课工场
 * @date 2024/6/1
 * @description
 */
public class TestCustomerRealm {

    public static void main(String[] args) {


        DefaultSecurityManager securityManager = new DefaultSecurityManager();
        CustomerRealm customerRealm = new CustomerRealm();
        securityManager.setRealm(customerRealm);

        SecurityUtils.setSecurityManager(securityManager);
        Subject subject = SecurityUtils.getSubject();
        subject.login(new UsernamePasswordToken("admin","12345"));
        boolean authenticated = subject.isAuthenticated();
        System.out.println("authenticated = " + authenticated);


    }
}
